<template>
  <div class="s-app-list" v-if="state.appList && state.appList.length > 0">
    <div class="appitem" @click="details" v-for="d in state.appList" :key="d.id">
      <dsfimg :src="d.applogo" :errorSrc="config.setting_img" />
      <div class="app-content">
        <p class="topText">{{ d.name }}</p>
        <p class="bottomText">{{ d.source }}</p>
        <p class="bottomText">发布时间:{{ d.releasetime }}</p>
      </div>
    </div>
  </div>
  <el-empty v-else></el-empty>
</template>
<script setup>
import { ref, reactive, onMounted, inject } from "vue";
import { useRouter } from "vue-router";
const http = inject("ajax");
const config = inject("config");
const loginState = inject("loginState");
const route = useRouter();
onMounted(() => {
  getData();
});
let state = reactive({
  appList: [],
});
const getData = () => {
  http("/iaiqsmde9fea569965ed56ab98ea0501752fe631902841e/indexAppList", {}, "GET")
    .then(res => {
      state.appList = res.data.appRecommend;
    })
    .catch(err => {
      console.log(err.message || "数据异常");
    });
};
const details = () => {
  loginState().then(() => {
    route.push({ path: "/AppListPage" });
  });
};
</script>
